package com.shide.flow.demo.engine;

import com.shide.flow.demo.core.FlowContext;
import com.shide.flow.demo.core.FlowCreator;
import com.shide.flow.demo.entity.FlowInstance;
import com.shide.flow.demo.entity.FlowProcess;
import com.shide.flow.demo.service.FlowProcessService;

import java.util.Map;

/**
 * @author yuwg
 */

public interface FlowEngine {

    /**
     * 配置实现类
     *
     * @param flowContext 全局配置类
     * @return 流程引擎
     */
    FlowEngine configure(FlowContext flowContext);

    FlowContext getContext();

    default FlowProcessService flowProcessService() {
        return getContext().getFlowProcessService();
    }

    /**
     * 启动流程实例
     *
     * @param processKey  流程定位key
     * @param flowCreator 流程任务创建者
     * @param args        参数列表
     * @return {@link FlowInstance} 流程实例
     */
    FlowInstance startInstanceByProcessKey(String processKey, FlowCreator flowCreator, Map<String, Object> args);

    /**
     * 根据流程对象 启动流程实例
     *
     * @param flowProcess 流程队形
     * @param flowCreator 流程任务创建者
     * @param args        参数列表
     * @return 流程实例
     */
    FlowInstance startProcessInstance(FlowProcess flowProcess, FlowCreator flowCreator, Map<String, Object> args);

}
